package com.xiu.travel.portal;

import com.alibaba.fastjson2.JSON;
import com.xiu.travel.portal.client.SearchClient;
import com.xiu.travel.portal.result.ApiResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;

import java.io.IOException;

/**
 * <p>
 * 搜索
 * </p>
 *
 * @author YuLing
 * @since 2023-10-13
 */
@RestController
@RequestMapping("/portal/admin/distribution/search")
@Tag(name = "航班搜索")
@Slf4j
public class SearchController {


    @Autowired
    private SearchClient searchClient;


    @PostMapping("flight/list")
    @Operation(summary = "搜索-查询航班列表")
    public ApiResult flightList(@RequestBody Object dto) throws IOException {
        return JSON.parseObject(searchClient.flightList(dto, OpenFeignConfig.TOKEN), ApiResult.class);
    }

    @PostMapping("flight/detail")
    @Operation(summary = "搜索-查询指定航班")
    public Object flightDetail(@RequestBody Object dto) {
        return JSON.parseObject(searchClient.flightDetail(dto, OpenFeignConfig.TOKEN), ApiResult.class);
    }

    @PostMapping("cabin/confirm")
    @Operation(summary = "搜索-验舱验价")
    public Object cabinConfirm(@RequestBody Object dto) {
        return JSON.parseObject(searchClient.cabinConfirm(dto, OpenFeignConfig.TOKEN), ApiResult.class);
    }
}
